package xyz.zdsoft.project_group_manage_module.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.zdsoft.common.utils.Result;
import xyz.zdsoft.project_group_manage_module.service.UpdateTeamLeaderGchService;

import javax.annotation.Resource;
import java.util.HashMap;

@RestController
@Api(tags = "项目组管理")
public class AdminUpdateTeamLeaderController {
    @Resource
    private UpdateTeamLeaderGchService updateTeamLeaderGchService;
    @ApiOperation("项目组更换/设置组长")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teamName",value = "项目组名称",required = true,example = "JAVA小组"),
            @ApiImplicitParam(name = "sId",value = "学生id",required = true,example = "1")
    })
    @PostMapping("/UpdateTeamLeader")
    public Result updateTeam(String teamName,Integer sId){
        HashMap<String,Object> map=new HashMap<>();
        map.put("teamName",teamName);
        map.put("sId",sId);
        if (updateTeamLeaderGchService.updateTeamLeader(map)>0){
            updateTeamLeaderGchService.updateTeamNoLeader(map);//将除组长外其他成员更新
            return Result.ok().message("更换组长成功");
        }else return Result.error().message("更换失败,也许是你输错了项目组名称或者该学生不在小组中");
    }
}
